﻿using UnityEngine;
using System.Collections;
using System.Xml;
public class EffectLaunchMissile : EffectGeneric
{
    public string AmmoUnit;            //弹药单位.
    public float AmmoLife;             //弹药生存时间.
    public EffectGeneric FinishEffect; //完成效果.
    public string AmmoMover;            //移动器.

    Unit AttackUnit; 

    public override void Init(XmlNode node,Unit unit)
    {
        base.Init(node,unit);

        
        this.AmmoUnit = node.Attributes["AmmoUnit"].Value;
        if (node.Attributes["FinishEffect"] != null) 
        {
            this.FinishEffect = EffectManager.Instance.CreateEffect(node.Attributes["FinishEffect"].Value,unit);
        }
        if (node.Attributes["AmmoLife"] != null) 
        {
            this.AmmoLife = float.Parse( node.Attributes["AmmoLife"].Value);
        }
        if (node.Attributes["AmmoMover"] != null) 
        {
            this.AmmoMover = node.Attributes["AmmoMover"].Value;
        }
    }

    public override void Exec()
    {
        this.AttackUnit = UnitManager.Instance.CreateUnit(this.AmmoUnit);
        this.AttackUnit.transform.localPosition = this.SrcUnit.transform.localPosition; 

        UnitManager.Instance.AddMover(this.AttackUnit,this.AmmoMover);
    }

    public override void Update()
    {
        base.Update();
    }
    
}
